PROJECT_NAME := GamingTool
SHELL := pwsh.exe
export .SHELLFLAGS := -NoProfile -Command

export CLANG :=  &"C:/toolchain/MSYS2/ucrt64/bin/clang++"
export LLD := &"C:/toolchain/MSYS2/ucrt64/bin/lld"

export ROOT := $(shell (Get-Location).toString() -replace("\\", "/") -replace(" ", "``u{20}"))
export _ROOT := $(shell (Get-Location).toString() -replace("\\", "/") -replace(" ", "\ "))

export SOURCE := $(ROOT)/source
export _SOURCE := $(_ROOT)/source

export BUILD := $(ROOT)/build
export _BUILD := $(_ROOT)/build

.PHONY: all dll exe

all: dll exe | build
dll: | build
	clang-cl /c $(SOURCE)/CursorClipper.cpp /GX /o$(BUILD)/ /I$(SOURCE)/include
	clang-cl /c $(SOURCE)/WindowUtil.cpp /GX /o$(BUILD)/ /I$(SOURCE)/include
	lld-link /out:$(BUILD)/GamingTool.dll /DLL /subsystem:console $(BUILD)/CursorClipper.obj $(BUILD)/WindowUtil.obj user32.lib kernel32.lib
exe: | build
	Ahk2Exe.exe /in $(SOURCE)/GamingTool.ahk /out $(BUILD)/$(PROJECT_NAME).exe
build:
	New-Item -Type Directory -Path $(BUILD)
clean:
	Remove-Item -Recurse $(BUILD)
